<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改消费信息</title>
<link rel="stylesheet" href="<%=request.getContextPath() %>/vendor/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="<%=request.getContextPath() %>/vendor/kindeditor/themes/default/default.css" />

<script src="<%=request.getContextPath() %>/vendor/jquery.min.js"></script>
<script src="<%=request.getContextPath() %>/vendor/bootstrap/js/bootstrap.js"></script>
<script src="<%=request.getContextPath() %>/vendor/layer-v3.1.1/layer/layer.js"></script>
<script src="<%=request.getContextPath() %>/vendor/nice-validator-1.1.4/dist/jquery.validator.js?local=zh-CN.js"></script>

<script src="<%=request.getContextPath() %>/vendor/kindeditor/kindeditor-all-min.js"></script>
<script src="<%=request.getContextPath() %>/vendor/kindeditor/lang/zh-CN.js"></script>

<script language="javascript" type="text/javascript" src="<%=request.getContextPath() %>/vendor/My97DatePicker/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
		<div class="container">
				
			<form id="classInfoForm" class="form-horizontal" action="javaScript:updateConsumeInfo();" method="POST" style="width:700px;  margin:0 auto ;  margin-top: 5px;">
	 			<input type="hidden" id="id" name="id" value="${consume.id }"> 
	 		 <div class="form-group">
			    <label for="consumeId" class="control-label">编号：</label>
			    <div>
			      <input type="text" class="form-control" id="consumeId" name="consumeId" value="${consume.id }" disabled="disabled">
			    </div>
	 		 </div>
	 
			  <div class="form-group">
			    <label for="name" class="control-label">商品名称：</label>
			    <div >
			      <input type="text" class="form-control" id="name" name="name" value="${consume.name }"  placeholder="请输入商品名称" data-rule="商品名称:required">
			    </div>
			  </div>
			  
			  <div class="form-group">
			    <label for="price" class="control-label">价格：</label>
			    <div >
			      <input type="text" class="form-control" id="price" name="price" value="${consume.price }"  placeholder="请输入价格(单位:元)"  data-rule="价格:required, range[0~100000000, false] ">
			    </div>
			  </div>
			  
			  <div class="form-group">
			    <label for="count" class="control-label">数量：</label>
			    <div>
			      <input type="text" class="form-control" id="count" name="count" value="${consume.count }"  placeholder="请输入数量" data-rule="数量:required, range[1~],integer[+]" >
			    </div>
			  </div>

			  <div class="form-group">
			  <label for="" class="control-label">消费类型：</label>
		           	 <select class="my-select form-control" name="typeName" style="height: 34px;" data-rule="类型:required">
					   	 <c:forEach items="${classList }" var="className" >
					        <option value="${className}" <c:if test="${className == typeName}">selected</c:if>>${className}</option>
				        </c:forEach>
				   	 </select>
	           </div>
			  
			  <div class="form-group">
			    <label for="date" class="control-label">申请时间：</label>
			    <input type="text" class="form-control" id="date" name="date" value="${consume.date }" placeholder="开始时间" data-rule="时间:required"  value="${pageModel.searchTimeStart }" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="readonly">
			  </div>
			  
			  <div class="form-group">
			    <label for="remark" class="control-label">备注信息：</label>
			    <div >
			      <textarea rows="10" id="remark" name="remark"  class="form-control">${consume.remark }</textarea>
			    </div>
			  </div>

			  <button type="submit" class="btn btn-primary">修改</button>
			  <button type="reset" class="btn btn-warning" onclick="history.back()">返回</button>
		</form>
		</div>
		
		<script>
			//修改消费信息
			function updateConsumeInfo(){

				var url = '<%=request.getContextPath()%>/consume/consumeServlet?method=updateConsumeInfo';
				
				$.post(url,$('#classInfoForm').serialize(),function(result){
					if(result == 'true'){
						location='<%=request.getContextPath() %>/consume/consumeServlet?method=searchConsume';
					}else{
						layer.alert('修改失败！' , {icon: 2});
					}
					
				});
			}
			
		</script>


</body>
</html>